package com.competitions.videoedithelper.controller;

import com.alibaba.fastjson.JSONObject;
import com.competitions.videoedithelper.entity.ResponseModel;
import com.competitions.videoedithelper.service.impl.VoiceRecognizeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Mapler
 */

@CrossOrigin
@RestController
@RequestMapping(value = "/voice")
public class VoiceRecognizeController {
    private VoiceRecognizeServiceImpl voiceRecognizeServiceImpl;

    @Autowired
    public VoiceRecognizeController(VoiceRecognizeServiceImpl voiceRecognizeServiceImpl) {
        this.voiceRecognizeServiceImpl = voiceRecognizeServiceImpl;
    }

    @RequestMapping(value = "/recognize",method = RequestMethod.POST)
    public ResponseModel recognizeVoice(@RequestBody JSONObject jsonObject) {
        return voiceRecognizeServiceImpl.recognizeVoice(jsonObject);
    }

    @RequestMapping(value = "/getResult",method = RequestMethod.GET)
    public ResponseModel getResult(@RequestParam("taskId")String textId){
        return voiceRecognizeServiceImpl.getRecognizeResult(textId);
    }

    @RequestMapping(value = "/checkResult",method = RequestMethod.GET)
    public ResponseModel checkResult(@RequestParam("videoId")int videoId){
        return voiceRecognizeServiceImpl.checkRecognizeResult(videoId);
    }


}
